n = 200; % dimension of permutations
p = 0.5;   % observation probability
q = 0.8; % probability of not being corrupted by (multiplicative) outlier noise, q=1 means no outlier noise
delta = 1;    % noise level in additive noise, delta=0 means no additive noise

Number_of_d = 9;   % number of points
Array_d = 5 + 5 * (1:Number_of_d)';   % number of permutations 


Number_of_Sim = 30;   % number of repeats


% 
figure;
set(gcf,'units','points','position',[10,10,800,400])
% title('d=5, observe p_1 = 0.1, noise p_2=0.7')

subplot(1,2,1);
set(gca,'fontsize',15)
plot(Array_d, 1 - sum(err_Spectral(:, 1:length(Array_d)))/Number_of_Sim,'-kp','LineWidth',2,'MarkerSize',10);
hold on
plot(Array_d, 1 - sum(err_GPM(:, 1:length(Array_d)))/Number_of_Sim,'-ro','LineWidth',2,'MarkerSize',10);
plot(Array_d, 1 - sum(err_QR(:, 1:length(Array_d)))/Number_of_Sim,'-g*','LineWidth',2,'MarkerSize',10);
hold off
legend('Spectral', 'GPM', 'QR','Location','northeast')
xlabel('\textbf{$d$}','Interpreter','latex')
ylabel('\textbf{Recovery Rate}','Interpreter','latex')


subplot(1,2,2);
set(gca,'fontsize',15)
plot(Array_d,sum(time_Spectral(:, 1:length(Array_d)))/(Number_of_Sim),'-kp','LineWidth',2,'MarkerSize',10);
hold on
plot(Array_d,sum(time_GPM(:, 1:length(Array_d)))/(Number_of_Sim),'-ro','LineWidth',2,'MarkerSize',10);
plot(Array_d,sum(time_QR(:, 1:length(Array_d)))/(Number_of_Sim),'-g*','LineWidth',2,'MarkerSize',10);
hold off
legend('Spectral', 'GPM','QR','Location','northwest')
xlabel('\textbf{$d$}','Interpreter','latex')
ylabel('\textbf{Time (s)}','Interpreter','latex')

% sgtitle(['$n$ = ', num2str(n), ', $p$ = ', num2str(p), ', $q$ = ', num2str(q), ', $\delta$ = ', num2str(delta)],'Interpreter','latex');

% Save
fig_name = ['n=', num2str(n) , '_d=', num2str(Array_d(1)),'-',num2str(Array_d(Number_of_d)), '_p=', num2str(p), '_q=', num2str(q), '_delta=', num2str(delta)];
% mkdir('C:\Users\AMA\Dropbox\Academics and Research\Research Projects\Working\Synchronization over Orthogonal Group\experiment2020\Permutation\Results',folder_name);
% save(['Results\',num2str(folder_name),'\err_Spec.mat'], 'err_Spectral');
% save(['Results\',num2str(folder_name),'\err_LUD.mat'], 'err_QR');
% save(['Results\',num2str(folder_name),'\err_GPM.mat'], 'err_GPM');
% save(['Results\',num2str(folder_name),'\time_Spec.mat'], 'time_Spectral');
% save(['Results\',num2str(folder_name),'\time_LUD.mat'], 'time_QR');
% save(['Results\',num2str(folder_name),'\time_GPM.mat'], 'time_GPM');
savefig(['C:\Users\mcyue\Dropbox\Academics and Research\Research Projects\Working\Synchronization over Orthogonal Group\Journal Paper\figures\',num2str(fig_name),'.fig']);